#include "PDTExp.h"
#include "PDTCodeGraph.h"
#include "PDTNumConst.h"

PDTExp::PDTExp(PDTCodeGraph & CG):PDTNode(CG){

}



PDTExpNum::PDTExpNum(PDTCodeGraph & CG):PDTExp(CG){
}



PDTExpBool::PDTExpBool(PDTCodeGraph & CG):PDTExpNum(CG){
}

PDTExpSet::PDTExpSet(PDTCodeGraph & CG): PDTExp(CG){
}

PDTUnresolvedExp PDTUnresolvedExp::unresolvedExp;

bool PDTUnaryNumExpr::eval(PDTCodeGraph &CG)
{
	children[0]->eval(CG);
	int expResult = (dynamic_cast<PDTNumConstInt*>(children[0]->nValue))->getValue();
	int result = expResult;
	if (this->unaryOp->isUnaryMinus())
		result = -expResult;
	nValue = new PDTNumConstInt(CG, result);
	return true;
}
